/*
* jinlanbao
*/
package com.jlb.zx.ctrl;

import com.alibaba.fastjson.JSON;
import com.jlb.core.entity.BeanRet;
import com.jlb.core.entity.Page;
import com.jlb.core.tools.redis.RedisUtils;
import com.jlb.zx.entity.ZxKuangFen;
import com.jlb.zx.service.ZxKuangFenSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
*  控制器
*
* @author jinlanbao
*/
@RestController
@RequestMapping("/zxKuangFen")
@Slf4j
@Api(value = "控制器", description = "控制器")
public class ZxKuangFenCtrl {

    @Resource
    protected RedisUtils redisUtils;

    @Resource
    private ZxKuangFenSV zxKuangFenSV;

    /**
    * 查询ZxKuangFen一个详情信息
    * @param id 
    * @return BeanRet
    */
    @ApiOperation(value = "查询ZxKuangFen一个详情信息", notes = "查询ZxKuangFen一个详情信息")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "",dataType = "java.lang.Long", paramType = "query")
    })
    @GetMapping(value = "/load")
    @ResponseBody
    public BeanRet load(Long id) {
        if(id==null){
        return null;
        }
        ZxKuangFen zxKuangFen = zxKuangFenSV.load(id);
        log.info(JSON.toJSONString(zxKuangFen));
        return BeanRet.create(true, "查询成功", zxKuangFen);
    }


    /**
    * 根据条件id查询ZxKuangFen一个详情信息
    *
    * @param id 
    * @return BeanRet
    */
    @ApiOperation(value = "查询ZxKuangFen一个详情信息", notes = "查询ZxKuangFen一个详情信息")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "id", value = "",dataType = "java.lang.Long", paramType = "path")
    })
    @GetMapping(value = "/load/id/{id}")
    @ResponseBody
    public BeanRet loadById(@PathVariable Long id) {
        if(id==null){
           return null;
        }
        ZxKuangFen zxKuangFen = zxKuangFenSV.loadById(id);
        log.info(JSON.toJSONString(zxKuangFen));
        return BeanRet.create(true, "查询成功", zxKuangFen);
    }


    /**
    * 查询ZxKuangFen信息集合
    *
    * @return 分页对象
    */
    @ApiOperation(value = "查询ZxKuangFen信息集合", notes = "查询ZxKuangFen信息集合")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    })
    @GetMapping(value = "/list")
    @ResponseBody
    public BeanRet list( @ApiIgnore ZxKuangFen zxKuangFen,Integer curPage,Integer pageSize) {
        Page<ZxKuangFen> page=new Page<ZxKuangFen>(pageSize,curPage);
        List<ZxKuangFen> zxKuangFens = zxKuangFenSV.list(zxKuangFen,page.genRowStart(),page.getPageSize());
        page.setVoList(zxKuangFens);
        int total = zxKuangFenSV.count(zxKuangFen);
        page.setTotalRow(total);

        return BeanRet.create(true, "查询成功", page);

    }


    /**
    * 查询ZxKuangFen信息集合
    *
    * @return 分页对象
    */
    @ApiOperation(value = "查询ZxKuangFen信息集合", notes = "查询ZxKuangFen信息集合")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    @ApiImplicitParam(name = "id", value = "", paramType = "query")
    })
    @GetMapping(value = "/list/by")
    @ResponseBody
    public BeanRet listByPk(Long id,Integer curPage,Integer pageSize) {
        Page<ZxKuangFen> page=new Page<ZxKuangFen>(pageSize,curPage);
        List<ZxKuangFen> zxKuangFens = zxKuangFenSV.list(id, page.genRowStart(),page.getPageSize());
        page.setVoList(zxKuangFens);
        int total = zxKuangFenSV.count(id);
        page.setTotalRow(total);

        return BeanRet.create(true, "查询成功", page);
    }

    /**
    * 统计ZxKuangFen信息数量根据主键
    *
    * @return 总条数
    */
    @ApiOperation(value = " 统计ZxKuangFen信息数量根据主键", notes = " 统计ZxKuangFen信息数量根据主键")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "", paramType = "query")
    })
    @GetMapping(value = "/count/by")
    @ResponseBody
    public Integer count(Long id) {
        return zxKuangFenSV.count(id);
    }

    /**
    * 统计ZxKuangFen信息数量
    *
    * @return 总条数
    */
    @ApiOperation(value = "统计ZxKuangFen信息数量", notes = "统计ZxKuangFen信息数量")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "kj1", value = "用户id", paramType = "query"),
    @ApiImplicitParam(name = "kj2", value = "用户编号", paramType = "query"),
    @ApiImplicitParam(name = "kj3", value = "统计用", paramType = "query"),
    @ApiImplicitParam(name = "kj4", value = "矿机ID", paramType = "query"),
    @ApiImplicitParam(name = "kj5", value = "购买时矿机价格", paramType = "query"),
    @ApiImplicitParam(name = "kj6", value = "创建时间", paramType = "query"),
    @ApiImplicitParam(name = "kj7", value = "JLB_KJ_002已产出", paramType = "query"),
    @ApiImplicitParam(name = "kj8", value = "修改时间", paramType = "query"),
    @ApiImplicitParam(name = "kj9", value = "JLB_KJ_003日收益", paramType = "query"),
    @ApiImplicitParam(name = "kj10", value = "运行周期", paramType = "query"),
    @ApiImplicitParam(name = "kj11", value = "状态0-停止1运行中", paramType = "query"),
    @ApiImplicitParam(name = "kj12", value = "JLB_KJ_004待收益数量算", paramType = "query"),
    @ApiImplicitParam(name = "kj13", value = "是否需要复投", paramType = "query"),
    @ApiImplicitParam(name = "kj14", value = "", paramType = "query")
    })
    @GetMapping(value = "/count")
    @ResponseBody
    public Integer count(@ApiIgnore ZxKuangFen zxKuangFen) {
        if(zxKuangFen==null){
            return zxKuangFenSV.count(new HashMap());
        }else{
            return zxKuangFenSV.count(zxKuangFen);
        }
    }



    /**
    * 创建ZxKuangFen
    *
    * @return BeanRet
    */
    @ApiOperation(value = "创建ZxKuangFen", notes = "创建ZxKuangFen")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "kj1", value = "用户id", paramType = "query"),
    @ApiImplicitParam(name = "kj2", value = "用户编号", paramType = "query"),
    @ApiImplicitParam(name = "kj3", value = "统计用", paramType = "query"),
    @ApiImplicitParam(name = "kj4", value = "矿机ID", paramType = "query"),
    @ApiImplicitParam(name = "kj5", value = "购买时矿机价格", paramType = "query"),
    @ApiImplicitParam(name = "kj6", value = "创建时间", paramType = "query"),
    @ApiImplicitParam(name = "kj7", value = "JLB_KJ_002已产出", paramType = "query"),
    @ApiImplicitParam(name = "kj8", value = "修改时间", paramType = "query"),
    @ApiImplicitParam(name = "kj9", value = "JLB_KJ_003日收益", paramType = "query"),
    @ApiImplicitParam(name = "kj10", value = "运行周期", paramType = "query"),
    @ApiImplicitParam(name = "kj11", value = "状态0-停止1运行中", paramType = "query"),
    @ApiImplicitParam(name = "kj12", value = "JLB_KJ_004待收益数量算", paramType = "query"),
    @ApiImplicitParam(name = "kj13", value = "是否需要复投", paramType = "query"),
    @ApiImplicitParam(name = "kj14", value = "", paramType = "query")
    })
    @PostMapping("/build")
    @ResponseBody
    public BeanRet build(@ApiIgnore ZxKuangFen zxKuangFen) {
        zxKuangFenSV.save(zxKuangFen);
        return BeanRet.create(true, "创建成功", zxKuangFen);
    }


    /**
    * 修改ZxKuangFen
    *
    * @return BeanRet
    */
    @ApiOperation(value = "修改ZxKuangFen", notes = "修改ZxKuangFen")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "", paramType = "query"),
        @ApiImplicitParam(name = "kj1", value = "用户id", paramType = "query"),
        @ApiImplicitParam(name = "kj2", value = "用户编号", paramType = "query"),
        @ApiImplicitParam(name = "kj3", value = "统计用", paramType = "query"),
        @ApiImplicitParam(name = "kj4", value = "矿机ID", paramType = "query"),
        @ApiImplicitParam(name = "kj5", value = "购买时矿机价格", paramType = "query"),
        @ApiImplicitParam(name = "kj6", value = "创建时间", paramType = "query"),
        @ApiImplicitParam(name = "kj7", value = "JLB_KJ_002已产出", paramType = "query"),
        @ApiImplicitParam(name = "kj8", value = "修改时间", paramType = "query"),
        @ApiImplicitParam(name = "kj9", value = "JLB_KJ_003日收益", paramType = "query"),
        @ApiImplicitParam(name = "kj10", value = "运行周期", paramType = "query"),
        @ApiImplicitParam(name = "kj11", value = "状态0-停止1运行中", paramType = "query"),
        @ApiImplicitParam(name = "kj12", value = "JLB_KJ_004待收益数量算", paramType = "query"),
        @ApiImplicitParam(name = "kj13", value = "是否需要复投", paramType = "query"),
        @ApiImplicitParam(name = "kj14", value = "", paramType = "query")
    })
    @PutMapping("/modify")
    @ResponseBody
    public BeanRet modify(@ApiIgnore ZxKuangFen zxKuangFen) {
        zxKuangFenSV.modify(zxKuangFen);
         return BeanRet.create(true, "修改成功", zxKuangFen);
    }

    /**
    * 删除ZxKuangFen
    *
    * @return BeanRet
    */
    @ApiOperation(value = "删除ZxKuangFen", notes = "删除ZxKuangFen")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "", paramType = "query")
    })
    @DeleteMapping("/delete")
    @ResponseBody
    public BeanRet delete(Long id) {
        zxKuangFenSV.delete(id);
        return BeanRet.create(true, "删除ZxKuangFen成功");
    }

}
